
const Mock = require('mockjs'); // 假数据

module.exports = function (app) {
    const prefix = '/api/stands/';

    app.get(prefix + 'droplist', (req, res) => {
        const code = 200;
        const msg = '';
        const data = Mock.mock({ // 生成
            'list|20': [{
                'id': '@increment(100)',
                'name': '@cname'
            }]
        });
        const time = +(new Date);
        const result = {code, data, msg, time};
        return res.end(JSON.stringify(result));
    });

    app.get(prefix + 'list', (req, res) => {
        const code = 200;
        const msg = '';
        const data = Mock.mock({ // 生成
            'list|20': [{
                'code': '@increment(100)',
                'ader_name': '@cname',
                'arrival_date': '@datetime',
                'recharge_type': 1,
                'arrival_money': '123123',
                'state': 0
            }],
            'rowcount': 200,
            'sum': {
                'arrival_money': '99999'
            }
        });
        const time = +(new Date);
        const result = {code, data, msg, time};
        return res.end(JSON.stringify(result));
    });

    app.post(prefix + 'edit', (req, res) => {
        const code = 200;
        const msg = '';
        const data = {'res_code': 1};
        const time = +(new Date);
        const result = {code, data, msg, time};
        return res.end(JSON.stringify(result));
    });
};
